package Applets;
import java.awt.*;
import java.applet.*;
import java.awt.event.*;

public class RandomCircles extends Applet implements ActionListener 
{
  // Draw some random circles.
  // Author: Elaine M. Baranowicz, October 29, 1996

  Button circleButton;
  
    @Override
  public void init () 
  {
    circleButton = new Button("Circle");
    add(circleButton);
    circleButton.addActionListener(this);
  }
  
    @Override
  public void paint (Graphics g) 
  {
    int diameter, radius, x, y,
    size = 255;
  
    // Generate a random center for the circle.
    x = (int) (size * Math.random());
    y = (int) (size * Math.random());
  
    // now randomly reduce the diameter
    diameter = (int) (size * Math.random());
    radius = (int)(diameter/2);
    Color c = new Color(x,y,diameter);
    g.setColor(c);
    g.drawOval(x-radius, y-radius, diameter, diameter);
  }
  
    @Override
  public void actionPerformed (ActionEvent event) 
  {
    //Graphics g = getGraphics();
	//paint(g);
    repaint();
  }

    @Override
  public void update (Graphics g) 
  {
    paint(g);
  }
}
